package symbolexp;

import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.util.logging.Logger;

import javax.swing.JFrame;
import javax.swing.JPanel;

public class PairImageGUI extends JPanel {
	final static Logger logger = Logger.getLogger(PairImageGUI.class.getName());
	Pair pr;
	SymbolState state;

	enum SymbolState {
		first, second, none
	}

	public PairImageGUI(Pair pr) {
		this.pr = pr;
		this.state = SymbolState.none;
		this.setPreferredSize(new Dimension(this.pr.firstSymbol.im.getWidth(),
				this.pr.firstSymbol.im.getHeight()));
		this.setMinimumSize(new Dimension(this.pr.firstSymbol.im.getWidth(),
				this.pr.firstSymbol.im.getHeight()));
	}

	public void paintComponent(Graphics g) {
		super.paintComponent(g);
		Graphics2D g2 = (Graphics2D) g;
		logger.info(pr.firstSymbol.name);
		if (this.state.equals(SymbolState.first)) {
			g2.drawImage(pr.firstSymbol.im, 0, 0, this);
		} else if (this.state.equals(SymbolState.second)) {
			g2.drawImage(pr.secondSymbol.im, g2.getTransform(), this);
		}

	}

	public static void main(String[] args) {
		JFrame app = new JFrame("PairImageGUI");
		app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		SymbolExperiment sym = new SymbolExperiment("");

		PairImageGUI prui = new PairImageGUI(sym.pairsList.get(0));

		prui.state = SymbolState.first;
		app.add(prui);
		app.pack();
		app.setVisible(true);

	}

}
